window.onload = function (){
    showLoginInfo();
    showOrder(1);
}
function showLoginInfo(){
    axios.get("/user/getLoginUser",null).then(e=>{
        var info = e.data;
        if (info == null || info =='') {
            location.href="/login.html?loginError=noManager";
        }
    })

}
async function showOrder(pageNo){
    var status= $("status");
   var index = status.selectedIndex;

    await axios.get("/manager/order/findByItem",{
        params:{
            pageNo,
            status:status.options[index].text,
            createDate:$("createDate"),
            endDate:$("endDate"),
        }
    }).then(e=>{
        var info = e.data;
        var str="";
        for (var i=0;i<info.records.length;i++){
            var obj = info.records[i];
            str+=`<tr>
<td>${obj.id}</td><td>${obj.sumPrice}</td><td>${obj.status}</td><td>${obj.createDate}</td><td><a href="/manager/findOrder.html?id=${obj.id}">查看详情</a></td>
</tr>`;
        }
        $("orderDiv").innerHTML = str;

        var cutPage = "";
        for(var i=1;i<= info.pages;i++){
            cutPage+=`<a href="javascript:showOrder(${i})">${i} </a>`
        }
        $("cutPageDiv").innerHTML =cutPage;

    })
}